import InstallCommon
import os


def DisplayConfigurePostgreSQLInstructions():

    FileName = '/etc/postgresql/9.3/main/postgresql.conf'
    print "Add the following lines to the file " + FileName
    print postgresql_conf
    


    FileName = '/etc/postgresql/9.3/main/pg_hba.conf'
    print "Add the following lines to the file " + FileName
    print pg_hba_conf


    print "\nRun the following PostGreSQL config commands:"
    print """    su -c "createuser root -s" postgres """
    print """    su -c "createuser technology -s" postgres"""
    print "Create the coopgis user and enter a password"
    print """    su -c "createuser coopgisdbuser -s -P" postgres\n\n"""

    Response = raw_input().lower()

def DisplayInitialDatabaseCreationInstructions():
    print "\nDrop the database if needed\n" + '    dropdb coopgis'
    print "Create the new database\n" + '    createdb coopgis'
    print "Add plpgsql to the database\n" + '    createlang plpgsql coopgis'
    print '    psql -d coopgis -c "CREATE EXTENSION postgis;"'
    print '    psql -d coopgis -c "CREATE EXTENSION postgis_topology;"'
    print '    /usr/bin/python /opt/coopgis/djangoproject/manage.py syncdb'
    
    print "\n"
    Response = raw_input().lower()


postgresql_conf = [
"listen_addresses = '*'	        	# what IP address(es) to listen on;",]


pg_hba_conf = [
'local   all             postgres                                peer',
'local   all             all                                     peer',
'host    all             all             0.0.0.0/0               md5',
'host    all             all             ::1/128                 md5',]
